package com.lmt_7;

import java.util.Arrays;
import java.util.function.IntUnaryOperator;

public class Arrayss {
    public static void main(String[] args) {
        int []arr = new int[] {10,20,60,40,50};
        String string = Arrays.toString(arr);
        System.out.println(string);

        int[] ints = Arrays.copyOfRange(arr, 0, 3);//拷贝数组包左不包右
        String string1 = Arrays.toString(ints);
        System.out.println(string1);

        int[] ints1 = Arrays.copyOf(arr, 6);
        String string2 = Arrays.toString(ints1);
        System.out.println(string2);

//        Arrays.setAll(arr, new IntUnaryOperator() {//数组整体改变
//            @Override
//            public int applyAsInt(int operand) {
//                return arr[operand] * 2;
//            }
//        });
        Arrays.setAll(arr,operand -> arr[operand]*2);
        System.out.println(Arrays.toString(arr));
        Arrays.sort(arr);//默认是升序排序
        System.out.println(Arrays.toString(arr));
    }
}
